package com.alvin.demo.job;

import org.quartz.*;

@DisallowConcurrentExecution
@PersistJobDataAfterExecution
public class MyJob implements Job {
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        JobDetail jobDetail = context.getJobDetail();
        JobDataMap jobDataMap = jobDetail.getJobDataMap();
        int count = (int) jobDataMap.get("count");
        System.out.println("第 " + count + " 次执行任务");
        jobDataMap.put("count" , ++count);
    }
}
